package argo.hot100.tree;

public class SortedArrayToBST {

    public TreeNode sortedArrayToBST(int[] nums) {

        return createChild(nums, 0, nums.length - 1);

    }

    public TreeNode createChild(int[] nums, int left, int right) {
        if (left > right) {
            return null;
        }
        int mid = (right - left) / 2 + left;
        TreeNode root = new TreeNode(nums[mid]);
        root.left = createChild(nums, left, mid - 1);
        root.right = createChild(nums, mid + 1, right);
        return root;

    }


}
